import axios from "axios"
import {ElNotification} from "element-plus";

async function  getAllDepartment(s){
    let formData = new FormData()
    formData.append("token", s)
    let res = []
    try {
        res = await new Promise((resolve, reject) => {
            axios.post(import.meta.env.VITE_APP_BASE_URL + "/api/getDepInfo", formData, {
                timeout: 1000,
                headers: {
                    "Content-Type": "multipart/form-data",
                },
            }).then(res => {
                if (res.status !== 200) {
                    reject("some errors happen status:" + res.status)
                } else {
                    resolve(res.data)
                }
            })
        })
    } catch (e) {
        ElNotification({
            title: "error",
            message: e
        })
       return []
    }
    return res
}


export {
    getAllDepartment
}